home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 080 (1988-11-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 080 (1988-11-15)(Ossowski, Stefan)(DE)(PD).adf / XBoot / XBoot.c < prev    next >
C/C++ Source or Header  |  1988-08-14  |  2KB  |  61 lines

  1. /* Conversion of a boot-block in an executable */
  2. /* Placed in Public Domain by Francois Rouaix in 1988 */
  3.  
  4. #include <libraries/dos.h>
  5.  
  6. char buffer[1024] ;
  7. long header[12] = { 0x000003f3,   /* Hunk_Header */
  8.                     0x00000000,   /* no hunk_name */
  9.                     0x00000002,   /* size of hunk_table */
  10.                     0x00000000,   /* first hunk */
  11.                     0x00000001,   /* last hunk */
  12.                     0x000000fd,   /* size of hunk 0 */
  13.                     0x00000003,   /* size of hunk 1 */
  14.                     0x000003e9,   /* hunk_code */
  15.                     0x000000fd,   /* size of hunk_code = 253 */
  16.                     /* end of header */
  17.                     0x000003ea,   /* hunk_data */
  18.                     0x00000003,   /* size */
  19.                     /* end of header */
  20.                     0x000003f2
  21.                   } ;
  22. /* xboot infile outfile */
  23.  
  24. main(argc,argv)
  25. int argc;
  26. char *argv[];
  27. {
  28.    struct FileHandle  *infile=0,*outfile=0 ;
  29.    int b=0;
  30.  
  31.    if (argc != 3) {
  32.       printf("Usage: %s infile outfile \n",argv[0]);
  33.       Exit(0);
  34.       }
  35.    if (!(infile = (struct FileHandle *)Open(argv[1],MODE_OLDFILE))) {
  36.       printf("Can't open %s\n",argv[1]);
  37.       Exit(0);
  38.       }
  39.    if (!(outfile = (struct FileHandle *)Open(argv[2],MODE_NEWFILE))) {
  40.       Close(infile);
  41.       printf("Can't open %s\n",argv[2]);
  42.       Exit(0);
  43.       }
  44.    b = Read(infile,&buffer[0],1024);
  45.    if (b != 1024)  printf("Warning ! Bad File.\n");
  46.    Close(infile);
  47.  
  48.  
  49.    Write(outfile,(char *)&header[0],4*9);        /* header */
  50.    Write(outfile,(char *)&buffer[12],4*253);     /* code */
  51.    Write(outfile,(char *)&header[11],4);       /* hunk_end */
  52.    Write(outfile,(char *)&header[9],4*2);        /* header for data */
  53.    Write(outfile,(char *)&buffer[0],4*3);        /* data */
  54.    Write(outfile,(char *)&header[11],4);       /* hunk_end */
  55.  
  56.  
  57.   Close(outfile);
  58. }
  59.  
  60.  
  61.